<template>
  <el-container class="h-100" v-loading="loading">
    <el-header class="shadow-sm d-flex justify-content-center bg-white" style="height: 80px;">
      <div class="w-100" style="line-height: 80px;">
        <h5 class="d-inline">外业审核进度监管</h5>
        <div class="float-right">
          <!-- 图斑和地类样本 -->
          <el-select placeholder="请选择" v-model="progressType" size="small" style="width: 150px;">
            <el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value">
            </el-option>
          </el-select>
          <el-date-picker :clearable="false" size="small" v-model="date" type="daterange" align="right"
            unlink-panels format="yyyy 年 MM 月 dd 日" value-format="yyyy-MM-dd" range-separator="至"
            start-placeholder="开始日期" end-placeholder="结束日期" :picker-options="pickerOptions">
          </el-date-picker>
          <el-button type="primary" icon="el-icon-search" size="small" @click="changedSearch">搜索</el-button>
          <el-button type="primary" @click="exportExcel" size="small">报表导出<i class="el-icon-download"></i></el-button>
        </div>
      </div>
    </el-header>
    <el-main class="m-2 bg-white">
      <el-table :data="datas" style="width: 100%" show-summary>
        <el-table-column label="序号" align="center" type="index">
        </el-table-column>
        <el-table-column prop="cityName" label="地市" align="center">
        </el-table-column>
        <el-table-column prop="areaName" label="区县" align="center">
        </el-table-column>
        <el-table-column prop="level1WaitReview" label="待初审" align="center" sortable>
        </el-table-column>
        <el-table-column prop="level1Fail" label="初审不通过" align="center" sortable>
        </el-table-column>
        <el-table-column prop="level1Pass" label="初审通过" align="center" sortable>
        </el-table-column>
        <el-table-column prop="level1Wait" label="初审待定" align="center" sortable>
        </el-table-column>
        <el-table-column prop="level2WaitReview" label="待复审" align="center" sortable>
        </el-table-column>
        <el-table-column prop="level2Fail" label="复审不通过" align="center" sortable>
        </el-table-column>
        <el-table-column prop="level2Pass" label="复审通过" align="center" sortable>
        </el-table-column>
      </el-table>
    </el-main>
  </el-container>
</template>
<script>
// import axios from "axios";

export default {
  name: "assessor-statis",
  title: "外业审核工作监管",
  data() {
    return {
      loading: false,
      progressType: "1",
      date: [this.$formatYMD(), this.$formatYMD()], // 设计只查询当天的统计数据，不需要用户输入日期
      datas: [],
      options: [
        {
          value: "1",
          label: "初次举证"
        },
        {
          value: "2",
          label: "地类样本"
        },
        {
          value: 1,
          label: "补充举证"
        },
        {
          value: "4",
          label: "外业核查"
        }
      ],
      pickerOptions: {
        shortcuts: [
          {
            text: "最近一周",
            onClick(picker) {
              const end = new Date();
              const start = new Date();
              start.setTime(start.getTime() - 3600 * 1000 * 24 * 7);
              picker.$emit("pick", [start, end]);
            }
          },
          {
            text: "最近一个月",
            onClick(picker) {
              const end = new Date();
              const start = new Date();
              start.setTime(start.getTime() - 3600 * 1000 * 24 * 30);
              picker.$emit("pick", [start, end]);
            }
          },
          {
            text: "最近三个月",
            onClick(picker) {
              const end = new Date();
              const start = new Date();
              start.setTime(start.getTime() - 3600 * 1000 * 24 * 90);
              picker.$emit("pick", [start, end]);
            }
          }
        ]
      }
    };
  },
  mounted() {
    this.changedSearch();
  },
  methods: {
    changedSearch() {
      this.loading = true;
      let url = 'analysis/spot/selectProvinceWorkStatistics'
      if (this.progressType === '4') {
        url = 'analysis/hc/spot/selectProvinceWorkStatistics'
      } else if (this.progressType === 1) {
        url = 'analysis/bc/spot/selectProvinceWorkStatistics'
      }
      this.$get(url, {
        type: this.progressType,
        aduitStartTime: `${this.date[0]} 00:00:00`,
        aduitEndTime: `${this.date[1]} 23:59:59`
      })
        .then(res => {
          this.datas = res.data.data;
        })
        .finally(() => {
          this.loading = false;
        });
    },
    exportExcel() {
      let obj = {
        type: this.progressType,
        oauth: this.$store.state.user.user.oauth,
        aduitStartTime: `${this.date[0]} 00:00:00`,
        aduitEndTime: `${this.date[1]} 23:59:59`
      };
      this.$exportExcel(
        this.$paramsConnect("analysis/downExcel/downProvinceWorkExcel", obj)
      );
    }
  }
};
</script>